package com.pavco.caribbeanvisit.client.event;

import java.util.ArrayList;

import com.google.gwt.event.shared.GwtEvent;
import com.pavco.caribbeanvisit.shared.models.Country;
import com.pavco.caribbeanvisit.client.eventhandlers.ReceivedCountriesWithAttrEventHandler;

public class ReceivedCountriesWithAttrEvent
    extends GwtEvent<ReceivedCountriesWithAttrEventHandler> {

  public static final GwtEvent.Type<ReceivedCountriesWithAttrEventHandler> TYPE =
      new GwtEvent.Type<ReceivedCountriesWithAttrEventHandler>();
  
  private Throwable caught;
  private ArrayList<Country> countries = new ArrayList<Country>();
  
  @Override
  protected void dispatch(ReceivedCountriesWithAttrEventHandler handler) {
    handler.onReceived(this);
  }

  @Override
  public com.google.gwt.event.shared.GwtEvent.Type<ReceivedCountriesWithAttrEventHandler> getAssociatedType() {
    return TYPE;
  }

  public void setCountries(ArrayList<Country> countries) {
    this.countries = countries;
  }

  public ArrayList<Country> getCountries() {
    return countries;
  }

  public void setError(Throwable caught) {
    this.caught = caught;
  }

  public Throwable getError() {
    return caught;
  }
  
  public boolean isFailed() {
    return (caught != null);
  }
}
